package com.hippo.common.base.util;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.hippo.common.base.model.ResponseDataModel;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;

/**
 * 返回值工具类
 */
@Slf4j
public class ResponseDataUtil {
    public static ResponseDataModel createResponseData(boolean success, String msg, Object responseData){
        ResponseDataModel responseDataModel = new ResponseDataModel();
        responseDataModel.setResponseData(ObjectUtil.isNotEmpty(responseData)?responseData:new HashMap<String,Object>());
        responseDataModel.setSuccess(success);
        responseDataModel.setMsg(msg);
        log.info("返回结果：");
        log.info(JSONUtil.toJsonStr(responseDataModel));
        return responseDataModel;
    }
}
